var t = require("../../utils/requestApi.js"), e = require("../../config/config.js");

Page({
    data: {
        fileDomainUrl: e.fileDomainUrl,
        person2Avatar: ""
    },
    copyText: function(t) {
        var e = t.currentTarget.dataset.text;
        wx.setClipboardData({
            data: e,
            success: function(t) {
                wx.hideToast(), wx.showToast({
                    title: "内容已复制",
                    icon: "success",
                    duration: 2e3
                });
            }
        });
    },
    previewImage: function(t) {
        var e = t.target.dataset.src;
        wx.previewImage({
            current: e,
            urls: [ e ]
        });
    },
    randomChange: function() {
        wx.showLoading({
            title: "让我找找...",
            mask: !0
        }), t.getChatRandom({}).then(function(t) {
            wx.hideLoading(), !0 === t.result && wx.redirectTo({
                url: "../detail3/detail3?random=1&chatId=" + t.obj.chatId + "&wxUserId=" + t.obj.wxUserId
            });
        });
    },
    openChat: function(t) {
        console.log(t);
        var e = t.target.dataset.chatid, a = t.target.dataset.wxuserid;
        !1 !== e && wx.redirectTo({
            url: "../detail3/detail3?chatId=" + e + "&wxUserId=" + a
        });
    },
    onLoad: function(e) {
        var a = this;
        1 == getCurrentPages().length ? a.setData({
            showBackToHome: !0
        }) : 1 == e.random ? a.setData({
            showRandomChange: !0
        }) : (a.setData({
            showPrevNext: !0
        }), t.getAdjacentChatId({
            chatId: e.chatId
        }).then(function(t) {
            console.log(t), a.setData({
                prevChatId: !!t.obj[0] && t.obj[0].chatId,
                prevWxUserId: !!t.obj[0] && t.obj[0].wxUserId,
                nextChatId: !!t.obj[1] && t.obj[1].chatId,
                nextWxUserId: !!t.obj[1] && t.obj[1].wxUserId
            });
        }));
        var o = {
            where: {
                chatId: e.chatId
            }
        };
        if (wx.showLoading({
            title: "请稍候...",
            mask: !0
        }), wx.showNavigationBarLoading(), t.getWordsList(o).then(function(t) {
            wx.hideLoading(), wx.hideNavigationBarLoading(), !0 === t.result && a.setData({
                wordsList: t.obj
            });
        }), e.wxUserId) {
            var n = {
                where: {
                    wxUserId: e.wxUserId
                }
            };
            t.getWxUserInfo(n).then(function(t) {
                !0 === t.result && 1 === t.obj.length && a.setData({
                    wxUser: t.obj[0]
                });
            });
        }
        var r = [ {
            title: "对方正在期待地搓搓手...",
            img: "../../resource/img/d1.jpeg"
        }, {
            title: "对方正在害羞...",
            img: "../../resource/img/d2.jpeg"
        }, {
            title: "对方正在脸红...",
            img: "../../resource/img/d3.jpeg"
        } ], i = r[Math.floor(Math.random() * r.length)];
        wx.setNavigationBarTitle({
            title: i.title
        });
        var s = Math.random() < .5;
        a.setData({
            person2Avatar: i.img,
            showAD: s
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});